/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.persistence.spring.dependency;

import org.springframework.core.Ordered;

import com.genia.toolbox.basics.exception.BundledException;

/**
 * this interface represents a dependency of a persistent object.
 * 
 * @param <TYPE>
 *          the type of the object this interface handles the dependencies
 */
public interface PersistableDependency<TYPE>
    extends Ordered
{
  /**
   * return the order in which this dependency must be executed.
   * 
   * @return the order in which this dependency must be executed
   */
  public abstract int getOrder();



  /**
   * Return the base type of the object handled by this class.
   * 
   * @return the base type of the object handled by this class
   */
  public Class<TYPE> getType();



  /**
   * handle the dependencies before updating an object.
   * 
   * @param object
   *          the object that will be updated
   * @throws BundledException
   *           when an error occurs
   */
  public abstract void onUpdate(TYPE object)
      throws BundledException;;



  /**
   * handle the dependencies before creating an object.
   * 
   * @param object
   *          the object that will be created
   * @throws BundledException
   *           when an error occurs
   */
  public abstract void onCreate(TYPE object)
      throws BundledException;;



  /**
   * handle the dependencies after creating an object.
   * 
   * @param object
   *          the object that has been created
   * @throws BundledException
   *           when an error occurs
   */
  public abstract void onPostCreate(TYPE object)
      throws BundledException;;



  /**
   * handle the dependencies before deleting an object.
   * 
   * @param object
   *          the object that will be deleted
   * @throws BundledException
   *           when an error occurs
   */
  public abstract void onDelete(TYPE object)
      throws BundledException;



  /**
   * handle the dependencies after updating an object.
   * 
   * @param object
   *          the object that has been updated
   * @throws BundledException
   *           when an error occurs
   */
  public abstract void onPostUpdate(TYPE object)
      throws BundledException;

}
